Developer Documentation
PATHJava Developer Documentation > Mac OS Runtime for Java > MRJToolkit > Programming With MRJToolkit


File Types and Creators

To identify and handle files properly, the Mac OS Finder requires two 4-byte identifiers: the file type and the creator. A file type is a string that specifies the contents of a file. For example, the file type 'APPL' identifies the file as an application and therefore executable. A file type of 'TEXT' means that the file contains raw text. Any application that can read raw text can open a file of type 'TEXT' .

However, many applications create files that contain application-specific information. For example, a word processor document might contain formatting and style information in addition to the raw text. Since only the application that created it can make use of the information, the application often assigns the file a proprietary file type.

To identify the application that created a document, the Finder relies on a string called a creator . For example, the SimpleText application (the default text editor installed with Mac OS system software) assigns the creator 'ttxt' to all its documents. If you double-click on a document that has the 'ttxt ' creator, the Finder knows to look for the SimpleText application to open it (the application also bears the creator 'ttxt') . The Finder also uses the creator to assign the "correct" icon to a file so that users can tell what application created it. Creators also allow the Finder to provide useful information about a file when you select the Get Info item in the File menu.

Note

Creators may not necessarily indicate the actual creator of a file, but rather what application should open it. For example, if you use an editor to create an HTML document, you might want to assign a browser's creator of the file rather than the HTML editor's creator. Double-clicking on the document then opens the appropriate browser rather than the HTML editor.

The MRJToolkit class com.apple.mrj.MRJFileUtils contains a number of methods that you can use to set the file type and creator of a file.

If you plan to publicly distribute your application, you must register its creator and any proprietary file types with Apple through Developer Technical Support to avoid collisions between names used by different developers. You can register a creator online or view currently registered creators at the following Web site:

http://developer.apple.com/dev/cftype/main.html

For more detailed information about how the Finder handles file types and creators, see the "Finder Interface" chapter in Inside Macintosh: Macintosh Toolbox Essentials .


© 1998 Apple Computer, Inc. — (Last Updated 10 Dec 98)